<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>const</title>
</head>
<body>
    <script>
        //声明常量
        const SCHOOL = '尚硅谷';
        //1.声明必须赋初始值
        //coust A  错误


        //2.标识符一般为大写
        const IDE = "IDEA";
        
        //3.不允许重复声明
        const TEACHER = "li";
        // const TEACHER = "zhang";


        //4.值不允许修改
        const MONEY = 100;

        // MONEY = 100-80;
        // console.log(MONEY);
        // Uncaught TypeError: Assignment to constant variable.
        //未捕获TypeError:赋值给常数变量

        //5.块儿级作用域
        {
            const NUMBER_STUDENT = 40;
            console.log(NUMBER_STUDENT);
        }
        
        // console.log(NUMBER_STUDENT);

        /**const.html:39 Uncaught ReferenceError: 
         * NUMBER_STUDENT is not definedat const.
         * html:39:21
         * 
         * 
        **/



        //6.对于数组和对象的元素修改，不算做对常量的修改，不会报错
        const TEAM = ['TeamA','TeamB','TeamC'];
        console.log(TEAM);

        TEAM.push('TeamAdd_C');
        console.log(TEAM);
        
    </script>
</body>
</html>




